package org.groupg.project.configmanager.ui;


import javax.swing.*;
import java.awt.*;

public class MainFrame extends JFrame {
    private JTabbedPane tabbedPane;
    private DatabaseConfigPanel databasePanel;
    private ApiConfigPanel apiPanel;
    private SshConfigPanel sshPanel;

    public MainFrame() {
        initializeUI();
    }

    private void initializeUI() {
        setTitle("配置管理工具");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(800, 600);
        setLocationRelativeTo(null);

        tabbedPane = new JTabbedPane();

        // 创建各个配置面板
        databasePanel = new DatabaseConfigPanel();
        apiPanel = new ApiConfigPanel();
        sshPanel = new SshConfigPanel();

        tabbedPane.addTab("数据库配置", databasePanel);
        tabbedPane.addTab("接口配置", apiPanel);
        tabbedPane.addTab("SSH配置", sshPanel);

        add(tabbedPane, BorderLayout.CENTER);

        // 菜单栏
        JMenuBar menuBar = new JMenuBar();
        JMenu fileMenu = new JMenu("文件");
        JMenuItem exitItem = new JMenuItem("退出");
        exitItem.addActionListener(e -> System.exit(0));
        fileMenu.add(exitItem);
        menuBar.add(fileMenu);
        setJMenuBar(menuBar);
    }
}
